Re: [GENERAL] Quoting/Escaping - Mailing list pgsql-general

From Herouth Maoz
Subject Re: [GENERAL] Quoting/Escaping
Date
Msg-id l03130301b4684ba9482e@[147.233.159.109]
Whole thread Raw
In response to Quoting/Escaping  (Bill Sneed <bsneed@mint.net>)
List pgsql-general
At 23:21 +0200 on 28/11/1999, Bill Sneed wrote:


> I'd like to be able to find a book title that contain C++ in the
> title....
>
> select * from books where title ~* 'C++'   doesn't work.
>
> I've tried all the basic methods of quoting the Plus (+) signs but
> none seem to work...
>
> Any hints would be most appreciated....

testing=> select * from test1;
tx
------------------------------------------------
I prefer Java to C++ programming.
C++ is the most complicated of all OO langagues.
Java has less inheritance, but it is simpler.
(3 rows)
testing=> select * from test1 where tx ~* 'C\\+\\+';
tx
------------------------------------------------
I prefer Java to C++ programming.
C++ is the most complicated of all OO langagues.
(2 rows)

Rationale: the string is processed in two stages. One, when the query is
read by Postgres. The other, when the regexp engine reads it. It needs to
have backslashes before the pluses when it reaches the second stage. So the
backslashes have to pass intact through the first stage. Thus, they have to
be escaped themselves...

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herouth/personal/



pgsql-general by date:

Previous
From: jose soares
Date:
Subject: Re: [GENERAL] update view
Next
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] Re: [GENERAL] drop/rename table and transactions